const fruits = ['apple', 'banana', 'apple'];
const count = fruits.reduce((acc, cur) => {
  acc[cur] = (acc[cur] || 0) + 1;
  return acc;
}, {});
// 结果：{ apple: 2, banana: 1 }